
	<div id='localteam' data-name='<?php echo $localteam; ?>' data-id='<?php echo $localteamId; ?>' ></div>
	<div id='visitorteam' data-name='<?php echo $visitorteam; ?>' data-id='<?php echo $visitorteamId; ?>' ></div>


	<?php $xmlh2h=simplexml_load_file("http://www.goalserve.com/getfeed/18945090b13942a5834efeec7eb903e2/h2h/".$localteamId."/".$visitorteamId); ?>
	
	<div id='total' data-games='<?php echo $xmlh2h->overall->total->total[0]->attributes()->games; ?>' 
					data-team1-won='<?php echo $xmlh2h->overall->total->total[1]->attributes()->team1_won; ?>' 
					data-team2-won='<?php echo $xmlh2h->overall->total->total[2]->attributes()->team2_won; ?>'
					data-draws='<?php echo $xmlh2h->overall->total->total[3]->attributes()->draws; ?>'  
					data-team1-scored='<?php echo $xmlh2h->goals->total->total[0]->attributes()->team1_scored; ?>'
					data-team1-conceded='<?php echo $xmlh2h->goals->total->total[1]->attributes()->team1_conceded; ?>'
					data-team2-scored='<?php echo $xmlh2h->goals->total->total[2]->attributes()->team2_scored; ?>'
					data-team2-conceded='<?php echo $xmlh2h->goals->total->total[3]->attributes()->team2_conceded; ?>'
					>
	</div>
	
	<div id='home' data-team1-won='<?php echo $xmlh2h->overall->home->team1[1]->attributes()->won; ?>' 
					data-team1-lost='<?php echo $xmlh2h->overall->home->team1[2]->attributes()->lost; ?>' 
					data-team1-draws='<?php echo $xmlh2h->overall->home->team1[3]->attributes()->draws; ?>'
					data-team2-won='<?php echo $xmlh2h->overall->home->team2[1]->attributes()->won; ?>' 
					data-team2-lost='<?php echo $xmlh2h->overall->home->team2[2]->attributes()->lost; ?>' 
					data-team2-draws='<?php echo $xmlh2h->overall->home->team2[3]->attributes()->draws; ?>' 
					data-team1-scored='<?php echo $xmlh2h->goals->home->home[0]->attributes()->team1_scored; ?>'
					data-team1-conceded='<?php echo $xmlh2h->goals->home->home[1]->attributes()->team1_conceded; ?>'
					data-team2-scored='<?php echo $xmlh2h->goals->home->home[2]->attributes()->team2_scored; ?>'
					data-team2-conceded='<?php echo $xmlh2h->goals->home->home[3]->attributes()->team2_conceded; ?>'
					>
	</div>
	
	<div id='away' data-team1-won='<?php echo $xmlh2h->overall->away->team1[1]->attributes()->won; ?>' 
					data-team1-lost='<?php echo $xmlh2h->overall->away->team1[2]->attributes()->lost; ?>' 
					data-team1-draws='<?php echo $xmlh2h->overall->away->team1[3]->attributes()->draws; ?>'
					data-team2-won='<?php echo $xmlh2h->overall->away->team2[1]->attributes()->won; ?>' 
					data-team2-lost='<?php echo $xmlh2h->overall->away->team2[2]->attributes()->lost; ?>' 
					data-team2-draws='<?php echo $xmlh2h->overall->away->team2[3]->attributes()->draws; ?>' 
					data-team1-scored='<?php echo $xmlh2h->goals->away->away[0]->attributes()->team1_scored; ?>'
					data-team1-conceded='<?php echo $xmlh2h->goals->away->away[1]->attributes()->team1_conceded; ?>'
					data-team2-scored='<?php echo $xmlh2h->goals->away->away[2]->attributes()->team2_scored; ?>'
					data-team2-conceded='<?php echo $xmlh2h->goals->away->away[3]->attributes()->team2_conceded; ?>'
					>
	</div>
	
	
	
	<div class="tournament container-fluid">
	        <div class="body-tournament-live row">
					<div class="col-md-12">
					        <div class="row">
					            <div class="localteam  col-md-6"><h3><?php echo $localteam; ?></h3></div>
					            <div class="visitorteam col-md-6"><h3><?php echo $visitorteam; ?></h3></div>
					        </div>
					</div>
					 <div class="col-md-12" style="padding-top: 20px;">

					   <!-- Nav tabs -->
					    <ul class="nav nav-tabs" role="tablist">
					      <li class="active"><a href="#statmatch" data-toggle="tab"><?php echo __("Risultato"); ?></a></li>
					      <li><a href="#statgoal" data-toggle="tab"><?php echo __("Goal"); ?></a></li>
					    </ul>
					    <!-- Tab panes -->
					    <div class="tab-content">
					      <div class="container-fluid tab-pane active" id="statmatch">
					      			<div class="row" >
					      				<div class="col-md-6" style="padding-top: 20px;">
							      			<div id="TEAM_MATCH_HOME_AWAY" class="chart" style='height:100%;width:100%;' ></div>
					      				</div>
					      				<div class="col-md-6" style="padding-top: 20px;">
					 					  	<div id="TEAM_MATCH" class="chart" style='height:100%;width:100%;' ></div>
					      				</div>
					      			</div>
					      </div>
					      <div class="container-fluid tab-pane active" id="statgoal">
					      	
					      			<div class="row" >
					      				<div class="col-md-12" style="padding-top: 20px;">
					 					  	<div id="GOAL_MATCH" class="chart" style='height:100%;width:100%;' ></div>
					      				</div>
					      			</div>
					      			<div class="row" >
					      				<div class="col-md-6" style="padding-top: 20px;">
					 					  	<div id="GOAL_LOCALTEAM" class="chart" style='height:100%;width:100%;' ></div>
					      				</div>
					      				<div class="col-md-6" style="padding-top: 20px;">
					 					  	<div id="GOAL_VISITORTEAM" class="chart" style='height:100%;width:100%;' ></div>
					      				</div>
					      			</div>
					      			
					      </div>
					    </div>
					 </div>
			</div>
	</div>


<script>

    $(document).ready(function() {
		loadCss("<?php echo Router::url( '/',true); ?>Wchart/css/jquery.jqplot.css");
		loadScript("<?php echo Router::url( '/',true); ?>js/jquery-ui-1.10.3.custom.min.js", function(){
				loadScript("<?php echo Router::url( '/',true); ?>Wchart/js/jqplot/jquery.jqplot.min.js", function(){
				   loadScript("<?php echo Router::url( '/',true); ?>Wchart/js/jqplot/plugins/jqplot.pieRenderer.min.js", function(){
				   loadScript("<?php echo Router::url( '/',true); ?>Wchart/js/jqplot/plugins/jqplot.donutRenderer.min.js", function(){
				   loadScript("<?php echo Router::url( '/',true); ?>Wchart/js/jqplot/plugins/jqplot.barRenderer.min.js", function(){
				   loadScript("<?php echo Router::url( '/',true); ?>Wchart/js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js", function(){
						loadScript("<?php echo $this->webroot; ?>Wchart/js/wchart.js", function(){
			
							console.log($('#localteam').data('id'));			
							console.log($('#visitorteam').data('id'));
							// inserire il codice 
							// data = [ [$('#localteam').data('name'),$('#total').data('team1-won')],
										// [$('#visitorteam').data('name'),$('#total').data('team2-won')],
										// ['Pareggiate',$('#total').data('draws')] ];
							data = [ ['1',$('#home').data('team1-won')],
										['X',$('#home').data('team1-draws')],
										['2',$('#home').data('team1-lost')] ];
						    drawChart('TEAM_MATCH','TEAM_MATCH','<?php echo __("Percentuale 1X2"); ?>',new Array(data));

							ticks = ['<?php echo __("Vittorie"); ?>','<?php echo __("Pareggi"); ?>','<?php echo __("Sconfitte"); ?>'];
							series = [{label:$('#localteam').data('name')},{label:$('#visitorteam').data('name')}];
							serie1 = [$('#home').data('team1-won'),$('#home').data('team1-draws'),$('#home').data('team1-lost')];
							serie2 = [$('#away').data('team2-won'),$('#away').data('team2-draws'),$('#away').data('team2-lost')];
							// console.log(homeVisitorteam);
						    drawChart('TEAM_MATCH_HOME_AWAY','TEAM_MATCH_HOME_AWAY','<?php echo __("Risultati precedenti"); ?>',new Array(serie1,serie2),ticks,series);
						    
						    goal = [ [$('#localteam').data('name'),$('#home').data('team1-scored')],[$('#visitorteam').data('name'),$('#away').data('team2-scored')] ];
						    drawChart('GOAL_MATCH','GOAL_MATCH','Goal',new Array(goal));
						    
							ticks = ['<?php echo __("Casa"); ?>','<?php echo __("Fuori Casa"); ?>'];
							series = [{label:'<?php echo __("Fatti"); ?>'},{label:'<?php echo __("Subiti"); ?>'}];
						    casa = [$('#home').data('team1-scored'),$('#away').data('team1-scored')];
						    fuoricasa = [$('#home').data('team1-conceded'),$('#away').data('team1-conceded')];
						    drawChart('GOAL_LOCALTEAM','GOAL_LOCALTEAM','Goal ' + $('#localteam').data('name'),new Array(casa,fuoricasa),ticks,series);
						    
							series = [{label:'<?php echo __("Fatti"); ?>'},{label:'<?php echo __("Subiti"); ?>'}];
						    casa = [$('#home').data('team2-scored'),$('#away').data('team2-scored')];
						    fuoricasa = [$('#home').data('team2-conceded'),$('#away').data('team2-conceded')];
						    drawChart('GOAL_VISITORTEAM','GOAL_VISITORTEAM','Goal ' + $('#visitorteam').data('name'),new Array(casa,fuoricasa),ticks,series);
						    
						    $('#statgoal').removeClass('active');
						    
		    
					});
				});
				});
				});
				});
			});
		});
    });

</script>
